<?php

require_once(WSB_MODULES_PATH . 'sherpa/models/CategoryGateway.php');

class Sherpa_BreadcrumbController extends WSB_Xtension_Extension
{

	/**
	 * @return string
	 */
	public function renderForBackend()
	{
		return get_class($this);
	}

	/**
	 * Index Action
	 */
	public function indexAction()
	{
		$gateway = new Sherpa_Model_CategoryGateway();
		$tree = $gateway->fetchTree($this->getLanguageId());
		$subCatId = $this->getParam('subcatId', 0);
		if(!empty($subCatId)) {
			$tree = $tree->getNode($subCatId);
			if($tree instanceof WSB_Model_SimpleTree) {
				$rootline = $tree->getRootline();
				$rootline->reverse();
				$this->_view->rootline = $rootline;
				$this->addContent($this->_view->render('breadcrumb/index.phtml'));
			}
		}
	}

}
